

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="深海火锅店">
  <meta name="keywords" content="">
  
    <meta name="description" content="vue3快速上手1vue create vue3-demo    ElementPlus1npm install element-plus --save   完整引入  12345678910&#x2F;&#x2F; main.tsimport &amp;#123; createApp &amp;#125; from &amp;#x27;vue&amp;#x27;import ElementPlus from &amp;#x27;element-plus&amp;">
<meta property="og:type" content="article">
<meta property="og:title" content="vue3快速上手">
<meta property="og:url" content="http://example.com/2023/04/30/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Vue/Vue3/Vue3%E9%80%9F%E6%88%90/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="vue3快速上手1vue create vue3-demo    ElementPlus1npm install element-plus --save   完整引入  12345678910&#x2F;&#x2F; main.tsimport &amp;#123; createApp &amp;#125; from &amp;#x27;vue&amp;#x27;import ElementPlus from &amp;#x27;element-plus&amp;">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202304300916024.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202304291523418.png">
<meta property="article:published_time" content="2023-04-30T02:50:00.000Z">
<meta property="article:modified_time" content="2024-02-15T16:04:19.050Z">
<meta property="article:author" content="深海火锅店">
<meta property="article:tag" content="vue3">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202304300916024.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>vue3快速上手 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fluid</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/background.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="vue3快速上手"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-04-30 10:50" pubdate>
          2023年4月30日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          14k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          114 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">vue3快速上手</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="vue3快速上手"><a href="#vue3快速上手" class="headerlink" title="vue3快速上手"></a>vue3快速上手</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">vue create vue3-demo<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202304300916024.png" srcset="/img/loading.gif" lazyload alt="image-20230430091624858"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202304291523418.png" srcset="/img/loading.gif" lazyload alt="创建vue3项目"></p>
<h2 id="ElementPlus"><a href="#ElementPlus" class="headerlink" title="ElementPlus"></a>ElementPlus</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install element-plus --save<br></code></pre></td></tr></table></figure>

<blockquote>
<p>完整引入</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// main.ts</span><br><span class="hljs-keyword">import</span> &#123; createApp &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">ElementPlus</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;element-plus&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-string">&#x27;element-plus/dist/index.css&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">App</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./App.vue&#x27;</span><br><br><span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>(<span class="hljs-title class_">App</span>)<br><br>app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">ElementPlus</span>)<br>app.<span class="hljs-title function_">mount</span>(<span class="hljs-string">&#x27;#app&#x27;</span>)<br></code></pre></td></tr></table></figure>

<blockquote>
<p>安装图标</p>
</blockquote>
<figure class="highlight coffeescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs coffeescript"><span class="hljs-built_in">npm</span> install @element-plus/icons-vue<br></code></pre></td></tr></table></figure>

<p><strong>图标注册</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// main.ts</span><br><br><span class="hljs-comment">// 如果您正在使用CDN引入，请删除下面一行。</span><br><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> <span class="hljs-title class_">ElementPlusIconsVue</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@element-plus/icons-vue&#x27;</span><br><br><span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>(<span class="hljs-title class_">App</span>)<br><span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> [key, component] <span class="hljs-keyword">of</span> <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">entries</span>(<span class="hljs-title class_">ElementPlusIconsVue</span>)) &#123;<br>  app.<span class="hljs-title function_">component</span>(key, component)<br>&#125;<br></code></pre></td></tr></table></figure>

<blockquote>
<p><code>综合</code></p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// main.ts</span><br><br><span class="hljs-keyword">import</span> &#123;createApp&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">App</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./App.vue&#x27;</span><br><span class="hljs-keyword">import</span> router <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./router&#x27;</span><br><span class="hljs-keyword">import</span> store <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./store&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">ElementPlus</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;element-plus&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-string">&#x27;element-plus/dist/index.css&#x27;</span><br><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> <span class="hljs-title class_">ElementPlusIconsVue</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@element-plus/icons-vue&#x27;</span><br><br><span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>(<span class="hljs-title class_">App</span>)<br><br>app.<span class="hljs-title function_">use</span>(store)<br>app.<span class="hljs-title function_">use</span>(router)<br>app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">ElementPlus</span>)<br><span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> [key, component] <span class="hljs-keyword">of</span> <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">entries</span>(<span class="hljs-title class_">ElementPlusIconsVue</span>)) &#123;<br>    app.<span class="hljs-title function_">component</span>(key, component)<br>&#125;<br>app.<span class="hljs-title function_">mount</span>(<span class="hljs-string">&#x27;#app&#x27;</span>)<br></code></pre></td></tr></table></figure>

<h2 id="axios"><a href="#axios" class="headerlink" title="axios"></a>axios</h2><blockquote>
<p>安装axios</p>
<p>以下内容参考【<a target="_blank" rel="noopener" href="https://blog.csdn.net/xqnode">程序员青戈</a>】的博客</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install axios -s<br></code></pre></td></tr></table></figure>

<p><strong>utils&#x2F;request.js</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">import</span> axios <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;axios&#x27;</span><br><br><span class="hljs-keyword">const</span> request = axios.<span class="hljs-title function_">create</span>(&#123;<br>	<span class="hljs-attr">baseURL</span>: <span class="hljs-string">&#x27;/api&#x27;</span>,  <span class="hljs-comment">// 注意！！ 这里是全局统一加上了 &#x27;/api&#x27; 前缀，也就是说所有接口都会加上&#x27;/api&#x27;前缀在，页面里面写接口的时候就不要加 &#x27;/api&#x27;了，否则会出现2个&#x27;/api&#x27;，类似 &#x27;/api/api/user&#x27;这样的报错，切记！！！</span><br>    <span class="hljs-attr">timeout</span>: <span class="hljs-number">5000</span><br>&#125;)<br><br><span class="hljs-comment">// request 拦截器</span><br><span class="hljs-comment">// 可以自请求发送前对请求做一些处理</span><br><span class="hljs-comment">// 比如统一加token，对请求参数统一加密</span><br>request.<span class="hljs-property">interceptors</span>.<span class="hljs-property">request</span>.<span class="hljs-title function_">use</span>(<span class="hljs-function"><span class="hljs-params">config</span> =&gt;</span> &#123;<br>    config.<span class="hljs-property">headers</span>[<span class="hljs-string">&#x27;Content-Type&#x27;</span>] = <span class="hljs-string">&#x27;application/json;charset=utf-8&#x27;</span>;<br>  <br> <span class="hljs-comment">// config.headers[&#x27;token&#x27;] = user.token;  // 设置请求头</span><br>    <span class="hljs-keyword">return</span> config<br>&#125;, <span class="hljs-function"><span class="hljs-params">error</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">Promise</span>.<span class="hljs-title function_">reject</span>(error)<br>&#125;);<br><br><span class="hljs-comment">// response 拦截器</span><br><span class="hljs-comment">// 可以在接口响应后统一处理结果</span><br>request.<span class="hljs-property">interceptors</span>.<span class="hljs-property">response</span>.<span class="hljs-title function_">use</span>(<br>    <span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> &#123;<br>        <span class="hljs-keyword">let</span> res = response.<span class="hljs-property">data</span>;<br>        <span class="hljs-comment">// 如果是返回的文件</span><br>        <span class="hljs-keyword">if</span> (response.<span class="hljs-property">config</span>.<span class="hljs-property">responseType</span> === <span class="hljs-string">&#x27;blob&#x27;</span>) &#123;<br>            <span class="hljs-keyword">return</span> res<br>        &#125;<br>        <span class="hljs-comment">// 兼容服务端返回的字符串数据</span><br>        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> res === <span class="hljs-string">&#x27;string&#x27;</span>) &#123;<br>            res = res ? <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(res) : res<br>        &#125;<br>        <span class="hljs-keyword">return</span> res;<br>    &#125;,<br>    <span class="hljs-function"><span class="hljs-params">error</span> =&gt;</span> &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;err&#x27;</span> + error) <span class="hljs-comment">// for debug</span><br>        <span class="hljs-keyword">return</span> <span class="hljs-title class_">Promise</span>.<span class="hljs-title function_">reject</span>(error)<br>    &#125;<br>)<br><br><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> request<br></code></pre></td></tr></table></figure>

<p><strong>vue.config.js</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 跨域配置</span><br><span class="hljs-variable language_">module</span>.<span class="hljs-property">exports</span> = &#123;<br>    <span class="hljs-attr">devServer</span>: &#123;                <span class="hljs-comment">//记住，别写错了devServer//设置本地默认端口  选填</span><br>        <span class="hljs-attr">port</span>: <span class="hljs-number">10020</span>,<br>        <span class="hljs-attr">proxy</span>: &#123;                 <span class="hljs-comment">//设置代理，必须填</span><br>            <span class="hljs-string">&#x27;/api&#x27;</span>: &#123;              <span class="hljs-comment">//设置拦截器  拦截器格式   斜杠+拦截器名字，名字可以自己定</span><br>                <span class="hljs-attr">target</span>: <span class="hljs-string">&#x27;http://localhost:10010&#x27;</span>,     <span class="hljs-comment">//代理的目标地址</span><br>                <span class="hljs-attr">changeOrigin</span>: <span class="hljs-literal">true</span>,              <span class="hljs-comment">//是否设置同源，输入是的</span><br>                <span class="hljs-attr">pathRewrite</span>: &#123;                   <span class="hljs-comment">//路径重写</span><br>                    <span class="hljs-string">&#x27;^/api&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>                     <span class="hljs-comment">//选择忽略拦截器里面的内容</span><br>                &#125;<br>            &#125;<br>        &#125;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="vuex"><a href="#vuex" class="headerlink" title="vuex"></a>vuex</h2><blockquote>
<p>安装vuex（已安装，main.ts配置参考element plus处）</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install vuex --save-dev<br></code></pre></td></tr></table></figure>

<blockquote>
<p>安装持久化插件</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm i vuex-persistedstate<br></code></pre></td></tr></table></figure>

<blockquote>
<p>关闭严格模式</p>
<p><code>tsconfig.json</code>里将<code>&quot;strict&quot;: false</code>设置为<code>&quot;strict&quot;: true</code></p>
</blockquote>
<p><strong>sotore&#x2F;modules&#x2F;userts</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;<br>    <span class="hljs-attr">namespaced</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">// 为每个模块添加一个前缀名，保证模块命明不冲突</span><br>    <span class="hljs-comment">// state中存放的就是全局共享的数据</span><br>    <span class="hljs-comment">// sessionStorage.getItem(&#x27;userState&#x27;)?JSON.parse(sessionStorage.getItem(&#x27;userState&#x27;))</span><br>    <span class="hljs-attr">state</span>: <span class="hljs-literal">null</span> != <span class="hljs-variable language_">window</span>.<span class="hljs-property">sessionStorage</span>.<span class="hljs-title function_">getItem</span>(<span class="hljs-string">&#x27;state&#x27;</span>) ? <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(sessionStorage.<span class="hljs-title function_">getItem</span>(<span class="hljs-string">&#x27;state&#x27;</span>)) : &#123;<br>        <span class="hljs-attr">user</span>: &#123;<br>            <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;&quot;</span>,<br>            <span class="hljs-attr">age</span>: <span class="hljs-literal">null</span>,<br>            <span class="hljs-attr">gender</span>: <span class="hljs-string">&quot;&quot;</span><br>        &#125;<br>    &#125;,<br><br>    <span class="hljs-comment">// 取值的方法，计算属性</span><br>    <span class="hljs-attr">getters</span>: &#123;<br>        <span class="hljs-title function_">getUser</span>(<span class="hljs-params">state</span>) &#123;<br>            <span class="hljs-keyword">return</span> state.<span class="hljs-property">user</span>;<br>        &#125;<br>    &#125;,<br>    <span class="hljs-comment">// 可以修改state值的方法，同步阻塞</span><br>    <span class="hljs-attr">mutations</span>: &#123;<br>        <span class="hljs-comment">// 传入user对象，更新全局的user</span><br>        <span class="hljs-title function_">updateUser</span>(<span class="hljs-params">state, user</span>) &#123;<br>            state.<span class="hljs-property">user</span> = user;<br>        &#125;<br>    &#125;,<br><br>    <span class="hljs-comment">// 异步调用mutations方法</span><br>    <span class="hljs-attr">actions</span>: &#123;<br>        <span class="hljs-title function_">asyncUpdateUser</span>(<span class="hljs-params">context, user</span>) &#123;<br>            context.<span class="hljs-title function_">commit</span>(<span class="hljs-string">&#x27;updateUser&#x27;</span>, user);<br>        &#125;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>



<p><strong>store&#x2F;indexts</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">import</span> &#123;createStore&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vuex&#x27;</span><br><span class="hljs-keyword">import</span> createPersistedState <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vuex-persistedstate&#x27;</span><br><span class="hljs-keyword">import</span> user <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./modules/user&#x27;</span><br><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-title function_">createStore</span>(&#123;<br>  <span class="hljs-attr">state</span>: &#123;<br>  &#125;,<br>  <span class="hljs-attr">getters</span>: &#123;<br>  &#125;,<br>  <span class="hljs-attr">mutations</span>: &#123;&#125;,<br>  <span class="hljs-attr">actions</span>: &#123;&#125;,<br>  <span class="hljs-attr">modules</span>: &#123;<br>    user<br>  &#125;,<br>  <span class="hljs-attr">plugins</span>: [<br>    <span class="hljs-comment">// 配置vuex插件</span><br>    <span class="hljs-comment">// 使用模块提供的方法</span><br>    <span class="hljs-title function_">createPersistedState</span>(&#123;<br>      <span class="hljs-comment">// 默认存储在localStorage 现改为sessionStorage</span><br>      <span class="hljs-attr">storage</span>: <span class="hljs-variable language_">window</span>.<span class="hljs-property">sessionStorage</span>,<br>      <span class="hljs-comment">// 本地存储数据的键名</span><br>      <span class="hljs-comment">// 配置存储持久化的key键名</span><br>      <span class="hljs-attr">key</span>: <span class="hljs-string">&#x27;user&#x27;</span>,<br>      <span class="hljs-comment">// 指定需要存储的模块，如果是模块下具体的数据需要加上模块名称，如user.token</span><br>      <span class="hljs-comment">// paths数组可以选择配置持久化的模块，不写代表所有</span><br>      <span class="hljs-comment">// paths: [&#x27;user&#x27;, &#x27;cart&#x27;]</span><br>    &#125;)<br>  ]<br>&#125;)<br></code></pre></td></tr></table></figure>

<blockquote>
<p>测试页面</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;template&gt;<br>  &lt;div class=&quot;hello&quot;&gt;<br>    &lt;el-button icon=&quot;Search&quot; circle @click=&quot;testVuex&quot; /&gt;<br>    &lt;br&gt;<br>    &lt;el-button type=&quot;success&quot; @click=&quot;clearDataFromVuex&quot;&gt;删除vuex内的数据&lt;/el-button&gt;<br>    &lt;br&gt;<br>    &lt;h3&gt;name:&#123;&#123; store.state.user.user.name &#125;&#125;&lt;/h3&gt;<br>    &lt;h3&gt;age:&#123;&#123; store.state.user.user.age &#125;&#125;&lt;/h3&gt;<br>    &lt;h3&gt;gender:&#123;&#123; store.state.user.user.gender &#125;&#125;&lt;/h3&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br><br>&lt;script lang=&quot;ts&quot;&gt;<br>import &#123;defineComponent, reactive, ref, computed&#125; from &#x27;vue&#x27;;<br>import &#123;useStore&#125; from &quot;vuex&quot;;<br><br>export default defineComponent(&#123;<br>  name: &#x27;HelloWorld&#x27;,<br>  props: &#123;<br>    msg: String,<br>  &#125;,<br>  setup() &#123;<br>    const store = useStore();<br><br>    const testVuex = () =&gt; &#123;<br>      // 使用这种方式可以改变值，但是无法实现数据的持久化<br>      // store.state.user.user.name=&#x27;假面骑士decade&#x27;<br>      // store.state.user.user.age=22<br>      // store.state.user.user.gender=&#x27;男&#x27;<br>		<br>      // 下面两种方法可以实现vuex的数据持久化<br>      // store.commit(&#x27;user/updateUser&#x27;,&#123;<br>      //   name: &quot;Decade&quot;,<br>      //   age: 22,<br>      //   gender: &quot;男&quot;<br>      // &#125;);<br><br>      store.dispatch(&#x27;user/asyncUpdateUser&#x27;, &#123;<br>        name: &quot;假面骑士&quot;,<br>        age: 18,<br>        gender: &quot;女&quot;<br>      &#125;);<br>    &#125;<br><br>    const clearDataFromVuex=()=&gt;&#123;<br>      store.dispatch(&#x27;user/asyncUpdateUser&#x27;, &#123;&#125;);<br>    &#125;;<br>    return &#123;<br>      testVuex,<br>      clearDataFromVuex,<br>      store<br>    &#125;<br>  &#125;<br>&#125;);<br>&lt;/script&gt;<br><br>&lt;style scoped lang=&quot;less&quot;&gt;<br>&lt;/style&gt;<br></code></pre></td></tr></table></figure>

<blockquote>
<p>简单集成ts</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;template&gt;<br>  &lt;div class=&quot;hello&quot;&gt;<br>    &lt;el-button icon=&quot;Search&quot; circle @click=&quot;testVuex&quot;/&gt;<br>    &lt;br&gt;<br>    &lt;el-button type=&quot;success&quot; @click=&quot;clearDataFromVuex&quot;&gt;删除vuex内的数据&lt;/el-button&gt;<br>    &lt;br&gt;<br>    &lt;h3&gt;name:&#123;&#123; store.state.user.user.name &#125;&#125;&lt;/h3&gt;<br>    &lt;h3&gt;age:&#123;&#123; store.state.user.user.age &#125;&#125;&lt;/h3&gt;<br>    &lt;h3&gt;gender:&#123;&#123; store.state.user.user.gender &#125;&#125;&lt;/h3&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br><br>&lt;script lang=&quot;ts&quot;&gt;<br>import &#123;defineComponent, reactive, ref, computed&#125; from &#x27;vue&#x27;;<br>import &#123;useStore&#125; from &quot;vuex&quot;;<br><br>interface userForm &#123;<br>  name: string,<br>  age: number,<br>  gender: string<br>&#125;<br><br>export default defineComponent(&#123;<br>  name: &#x27;HelloWorld&#x27;,<br>  props: &#123;<br>    msg: String,<br>  &#125;,<br>  setup() &#123;<br>    const store = useStore();<br><br>    const testVuex = (user: userForm) =&gt; &#123;<br>      user = &#123;<br>        name: &quot;Decade&quot;,<br>        age: 22,<br>        gender: &quot;男&quot;<br>      &#125;;<br>      store.commit(&#x27;user/updateUser&#x27;, user);<br>    &#125;<br><br>    const clearDataFromVuex = () =&gt; &#123;<br>      store.dispatch(&#x27;user/asyncUpdateUser&#x27;, &#123;&#125;);<br>    &#125;;<br>    return &#123;<br>      testVuex,<br>      clearDataFromVuex,<br>      store<br>    &#125;<br>  &#125;<br>&#125;);<br>&lt;/script&gt;<br><br>&lt;style scoped lang=&quot;less&quot;&gt;<br>&lt;/style&gt;<br></code></pre></td></tr></table></figure>

<h2 id="cookie"><a href="#cookie" class="headerlink" title="cookie"></a>cookie</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install vue-cookies --save<br></code></pre></td></tr></table></figure>

<blockquote>
<p>main.ts</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">import</span> &#123;createApp&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">App</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./App.vue&#x27;</span><br><span class="hljs-keyword">import</span> router <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./router&#x27;</span><br><span class="hljs-keyword">import</span> store <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;./store&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">ElementPlus</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;element-plus&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-string">&#x27;element-plus/dist/index.css&#x27;</span><br><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> <span class="hljs-title class_">ElementPlusIconsVue</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@element-plus/icons-vue&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-string">&#x27;@/assets/css/global.css&#x27;</span><br><span class="hljs-keyword">import</span> <span class="hljs-title class_">VueCookies</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue-cookies&#x27;</span><br><br><span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>(<span class="hljs-title class_">App</span>)<br><br>app.<span class="hljs-title function_">use</span>(store)<br>app.<span class="hljs-title function_">use</span>(router)<br>app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">ElementPlus</span>)<br><span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> [key, component] <span class="hljs-keyword">of</span> <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">entries</span>(<span class="hljs-title class_">ElementPlusIconsVue</span>)) &#123;<br>    app.<span class="hljs-title function_">component</span>(key, component)<br>&#125;<br><span class="hljs-comment">// @ts-ignore</span><br>app.<span class="hljs-property">config</span>.<span class="hljs-property">globalProperties</span>.<span class="hljs-property">$cookies</span> = <span class="hljs-title class_">VueCookies</span>;<br><br>app.<span class="hljs-title function_">mount</span>(<span class="hljs-string">&#x27;#app&#x27;</span>)<br></code></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;template&gt;<br>  &lt;div class=&quot;cookie-test&quot;&gt;<br>    &lt;el-button @click=&quot;cookieInTest&quot;&gt;点击存入cookie&lt;/el-button&gt;<br>    &lt;el-button @click=&quot;cookieDeleteTest&quot;&gt;点击删除cookie&lt;/el-button&gt;<br>    &lt;br&gt;<br>    &lt;span&gt;cookieForm:&#123;&#123;cookieForm&#125;&#125;&lt;/span&gt;<br>    &lt;br&gt;<br>    &lt;span&gt;mydata:&#123;&#123;myData&#125;&#125;&lt;/span&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script lang=&quot;ts&quot;&gt;<br>import &#123;defineComponent, getCurrentInstance, ref,onMounted&#125; from &#x27;vue&#x27;;<br>import VueCookies from &#x27;vue-cookies&#x27;<br><br>export default defineComponent(&#123;<br>  name: &#x27;&#x27;,<br>  setup()&#123;<br>    let cookieForm=ref();<br>    let internalInstance = getCurrentInstance();<br>    let cookies = internalInstance.appContext.config.globalProperties.$cookies<br><br>    const cookieInTest=()=&gt;&#123;<br>      // 存入，可加时间限制(秒)<br>      // cookies.set(&#x27;test&#x27;, &#x27;Hello world!&#x27;,5);<br>      // cookies.set(&#x27;test&#x27;, &#x27;Hello world!&#x27;,5000);<br>      // 获取<br>      // cookieForm.value=cookies.get(&#x27;test&#x27;);<br><br>      // 将数据保存到cookie中<br>      cookies.set(&#x27;myData&#x27;, &#x27;测试数据&#x27;, &#x27;30d&#x27;)<br>      myData.value=cookies.get(&#x27;myData&#x27;);<br>      console.log(&quot;set--mydata,&quot;,myData.value);<br>    &#125;<br><br>    const cookieDeleteTest=()=&gt;&#123;<br>      // cookies.remove(&#x27;test&#x27;);<br>      // 获取<br>      // cookieForm.value=cookies.get(&#x27;test&#x27;);<br>      cookies.remove(&#x27;myData&#x27;);<br>      myData.value=cookies.get(&#x27;myData&#x27;);<br>    &#125;<br><br>    const createdData=()=&gt;&#123;<br>      // cookieForm = cookies.get(&#x27;myData&#x27;)<br>    &#125;<br><br>    const myData = ref(&#x27;&#x27;)<br><br>    onMounted(() =&gt; &#123;<br>      // 从cookie中读取数据<br>      myData.value = cookies.get(&#x27;myData&#x27;)<br>      console.log(&quot;mydata,&quot;,myData.value);<br>    &#125;)<br>    return &#123;<br>      cookieForm,<br>      cookieInTest,<br>      cookieDeleteTest,<br>      myData<br>    &#125;<br>  &#125;<br>&#125;)<br>&lt;/script&gt;<br></code></pre></td></tr></table></figure>

<h2 id="工具类"><a href="#工具类" class="headerlink" title="工具类"></a>工具类</h2><blockquote>
<p>util&#x2F;index.js</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">import</span> <span class="hljs-title class_">Vue</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span><br><span class="hljs-keyword">import</span> &#123;<span class="hljs-title class_">Router</span> <span class="hljs-keyword">as</span> router&#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;vue-router&quot;</span>;<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 获取uuid</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@returns</span> &#123;<span class="hljs-type">string</span>&#125; <span class="hljs-variable">uuid</span></span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">getUUID</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-string">&#x27;xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx&#x27;</span>.<span class="hljs-title function_">replace</span>(<span class="hljs-regexp">/[xy]/g</span>, <span class="hljs-function"><span class="hljs-params">c</span> =&gt;</span> &#123;<br>        <span class="hljs-keyword">return</span> (c === <span class="hljs-string">&#x27;x&#x27;</span> ? (<span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>() * <span class="hljs-number">16</span> | <span class="hljs-number">0</span>) : (<span class="hljs-string">&#x27;r&amp;0x3&#x27;</span> | <span class="hljs-string">&#x27;0x8&#x27;</span>)).<span class="hljs-title function_">toString</span>(<span class="hljs-number">16</span>)<br>    &#125;)<br>&#125;<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 是否有权限</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> &#123;<span class="hljs-type">*</span>&#125; <span class="hljs-variable">key</span></span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">isAuth</span> (key) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(sessionStorage.<span class="hljs-title function_">getItem</span>(<span class="hljs-string">&#x27;permissions&#x27;</span>) || <span class="hljs-string">&#x27;[]&#x27;</span>).<span class="hljs-title function_">indexOf</span>(key) !== -<span class="hljs-number">1</span> || <span class="hljs-literal">false</span><br>&#125;<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 树形数据转换</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> &#123;<span class="hljs-type">*</span>&#125; <span class="hljs-variable">data</span></span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> &#123;<span class="hljs-type">*</span>&#125; <span class="hljs-variable">id</span></span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> &#123;<span class="hljs-type">*</span>&#125; <span class="hljs-variable">pid</span></span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">treeDataTranslate</span> (data, id = <span class="hljs-string">&#x27;id&#x27;</span>, pid = <span class="hljs-string">&#x27;parentId&#x27;</span>) &#123;<br>    <span class="hljs-keyword">const</span> res = [];<br>    <span class="hljs-keyword">const</span> temp = &#123;&#125;;<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; data.<span class="hljs-property">length</span>; i++) &#123;<br>        temp[data[i][id]] = data[i]<br>    &#125;<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> k = <span class="hljs-number">0</span>; k &lt; data.<span class="hljs-property">length</span>; k++) &#123;<br>        <span class="hljs-keyword">if</span> (temp[data[k][pid]] &amp;&amp; data[k][id] !== data[k][pid]) &#123;<br>            <span class="hljs-keyword">if</span> (!temp[data[k][pid]][<span class="hljs-string">&#x27;children&#x27;</span>]) &#123;<br>                temp[data[k][pid]][<span class="hljs-string">&#x27;children&#x27;</span>] = []<br>            &#125;<br>            <span class="hljs-keyword">if</span> (!temp[data[k][pid]][<span class="hljs-string">&#x27;_level&#x27;</span>]) &#123;<br>                temp[data[k][pid]][<span class="hljs-string">&#x27;_level&#x27;</span>] = <span class="hljs-number">1</span><br>            &#125;<br>            data[k][<span class="hljs-string">&#x27;_level&#x27;</span>] = temp[data[k][pid]].<span class="hljs-property">_level</span> + <span class="hljs-number">1</span><br>            temp[data[k][pid]][<span class="hljs-string">&#x27;children&#x27;</span>].<span class="hljs-title function_">push</span>(data[k])<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>            res.<span class="hljs-title function_">push</span>(data[k])<br>        &#125;<br>    &#125;<br>    <span class="hljs-keyword">return</span> res<br>&#125;<br><br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 清除登录信息</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">clearLoginInfo</span> () &#123;<br>    <span class="hljs-comment">// Vue.cookie.delete(&#x27;token&#x27;)</span><br>    <span class="hljs-comment">// store.commit(&#x27;resetStore&#x27;)</span><br>    <span class="hljs-comment">// router.options.isAddDynamicMenuRoutes = false</span><br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="qs"><a href="#qs" class="headerlink" title="qs"></a>qs</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install qs --save<br></code></pre></td></tr></table></figure>

<h3 id="qs的使用"><a href="#qs的使用" class="headerlink" title="qs的使用"></a><strong>qs的使用</strong></h3><h4 id="parse"><a href="#parse" class="headerlink" title="parse"></a>parse</h4><blockquote>
<p>将<code>url</code>的参数转化为<code>object</code>对象</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">const</span> str = <span class="hljs-string">&quot;name=%E9%A9%AC%E5%B0%8F%E8%B7%B3&amp;age=12&amp;address=%E5%BC%82%E6%AC%A1%E5%85%83&#x27;&quot;</span> <br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(qs.<span class="hljs-title function_">parse</span>(str)) <span class="hljs-comment">// Object &#123;name: &quot;马小跳&quot;,age: &quot;12&quot;,address: &quot;异次元&quot;&#125;</span><br></code></pre></td></tr></table></figure>



<h4 id="stringfy"><a href="#stringfy" class="headerlink" title="stringfy"></a>stringfy</h4><blockquote>
<p>将<code>对象</code>转为<code>url参数</code>格式</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(qs.<span class="hljs-title function_">stringify</span>(&#123;<br>  <span class="hljs-attr">name</span>:<span class="hljs-string">&#x27;马小跳&#x27;</span>,<br>  <span class="hljs-attr">age</span>:<span class="hljs-number">12</span>,<br>  <span class="hljs-attr">address</span>:<span class="hljs-string">&#x27;异次元&#x27;</span><br>&#125;))<br><span class="hljs-comment">// logs name=%E9%A9%AC%E5%B0%8F%E8%B7%B3&amp;age=12&amp;address=%E5%BC%82%E6%AC%A1%E5%85%83</span><br></code></pre></td></tr></table></figure>

<h2 id="echarts"><a href="#echarts" class="headerlink" title="echarts"></a>echarts</h2><blockquote>
<p><a target="_blank" rel="noopener" href="https://echarts.apache.org/zh/index.html">echarts官网</a></p>
</blockquote>
<blockquote>
<p>数据可视化</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install echarts --save<br></code></pre></td></tr></table></figure>

<blockquote>
<p>main.ts内引入</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 全局引入相关包</span><br><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> echarts <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;echarts&quot;</span>;<br><span class="hljs-comment">// 开启echarts</span><br>app.<span class="hljs-property">config</span>.<span class="hljs-property">globalProperties</span>.<span class="hljs-property">$echarts</span> = echarts;<br></code></pre></td></tr></table></figure>

<blockquote>
<p>组件内使用</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;template&gt;<br>  &lt;div id=&quot;myChart&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script lang=&quot;ts&quot;&gt;<br>import &#123;defineComponent, toRefs, reactive, onMounted&#125; from &#x27;vue&#x27;<br>import * as echarts from &#x27;echarts&#x27;<br><br>export default defineComponent(&#123;<br>  name: &#x27;EchartsTest&#x27;,<br>  setup() &#123;<br>    const state = reactive(&#123;<br>      option: &#123;<br>        title: &#123;<br>          text: &#x27;Referer of a Website&#x27;,<br>          subtext: &#x27;Fake Data&#x27;,<br>          left: &#x27;center&#x27;<br>        &#125;,<br>        tooltip: &#123;<br>          trigger: &#x27;item&#x27;<br>        &#125;,<br>        legend: &#123;<br>          orient: &#x27;vertical&#x27;,<br>          left: &#x27;left&#x27;<br>        &#125;,<br>        grid: &#123;<br>          top: &#x27;4%&#x27;,<br>          left: &#x27;2%&#x27;,<br>          right: &#x27;4%&#x27;,<br>          bottom: &#x27;0%&#x27;,<br>          containLabel: true,<br>        &#125;,<br>        series: [<br>          &#123;<br>            name: &#x27;Access From&#x27;,<br>            type: &#x27;pie&#x27;,<br>            radius: &#x27;50%&#x27;,<br>            data: [<br>              &#123; value: 1048, name: &#x27;Search Engine&#x27; &#125;,<br>              &#123; value: 735, name: &#x27;Direct&#x27; &#125;,<br>              &#123; value: 580, name: &#x27;Email&#x27; &#125;,<br>              &#123; value: 484, name: &#x27;Union Ads&#x27; &#125;,<br>              &#123; value: 300, name: &#x27;Video Ads&#x27; &#125;<br>            ],<br>            emphasis: &#123;<br>              itemStyle: &#123;<br>                shadowBlur: 10,<br>                shadowOffsetX: 0,<br>                shadowColor: &#x27;rgba(0, 0, 0, 0.5)&#x27;<br>              &#125;<br>            &#125;<br>          &#125;<br>        ]<br>      &#125;,<br>    &#125;)<br>    const initEcharts = () =&gt; &#123;<br>      let myChart = echarts.init(document.getElementById(&#x27;myChart&#x27;))<br>      // 绘制图表<br>      myChart.setOption(state.option)<br>    &#125;<br><br>    onMounted(() =&gt; &#123;<br>      initEcharts()<br>    &#125;)<br><br>    return &#123;<br>      ...toRefs(state),<br>    &#125;<br>  &#125;,<br>&#125;)<br>&lt;/script&gt;<br>&lt;style scoped&gt;<br>#myChart&#123;<br>  width: 700px;<br>  height: 700px;<br>&#125;<br>&lt;/style&gt;<br></code></pre></td></tr></table></figure>



<h2 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h2><h3 id="常用依赖"><a href="#常用依赖" class="headerlink" title="常用依赖"></a>常用依赖</h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_41897680/article/details/107560873">博客</a></p>
</blockquote>
<h3 id="常用库"><a href="#常用库" class="headerlink" title="常用库"></a>常用库</h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_44757034/article/details/128090797">博客</a></p>
</blockquote>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/vue3/" class="category-chain-item">vue3</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/vue3/">#vue3</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>vue3快速上手</div>
      <div>http://example.com/2023/04/30/编程语言/Vue/Vue3/Vue3速成/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>深海火锅店</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年4月30日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2023/04/30/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Vue/Vue3/Vue3+Typescript/" title="vue3 &amp; typescript学习">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">vue3 &amp; typescript学习</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2023/04/19/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Js&amp;JQuery/JavaScript&amp;JQuery%E5%A4%8D%E4%B9%A0/" title="JavaScript&amp;JQuery复习">
                        <span class="hidden-mobile">JavaScript&amp;JQuery复习</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="//cdn.jsdelivr.net/gh/EmoryHuang/BlogBeautify@1.1/DynamicRibbon.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
